home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / os2 / octa209s.zip / octave-2.09 / liboctave / safe-xstat.hin < prev    next >
Text File  |  1996-01-23  |  2KB  |  79 lines

  1. /* safe-@l@stat.h -- EINTR-safe interface to @l@stat
  2.    Copyright (C) 1994 Free Software Foundation, Inc.
  3.  
  4.    This program is free software; you can redistribute it and/or modify
  5.    it under the terms of the GNU General Public License as published by
  6.    the Free Software Foundation; either version 2, or (at your option)
  7.    any later version.
  8.  
  9.    This program is distributed in the hope that it will be useful,
  10.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12.    GNU General Public License for more details.
  13.  
  14.    You should have received a copy of the GNU General Public License
  15.    along with this program; if not, write to the Free Software
  16.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  17.    
  18. /* Written by Jim Meyering <meyering@comco.com>.  */
  19.  
  20. #ifndef _safe_@l@stat_h_
  21. #define _safe_@l@stat_h_ 1
  22.  
  23. #ifdef __cplusplus
  24. extern "C" {
  25. #endif
  26.  
  27. /* NOTE: you must include the following headers (in the listed order)
  28.    before this one: <sys/types.h>, <sys/stat.h>.  */
  29.  
  30. #if !defined(S_ISLNK) && defined(S_IFLNK)            @LSTAT_ONLY@
  31. #define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)            @LSTAT_ONLY@
  32. #endif                                @LSTAT_ONLY@
  33.                                 @LSTAT_ONLY@
  34. #ifndef S_ISLNK                            @LSTAT_ONLY@
  35. #include "safe-stat.h"                        @LSTAT_ONLY@
  36. #define SAFE_LSTAT SAFE_STAT                    @LSTAT_ONLY@
  37. #define safe_lstat safe_stat                    @LSTAT_ONLY@
  38. #else                                @LSTAT_ONLY@
  39.                                 @LSTAT_ONLY@
  40. #include <errno.h>
  41.  
  42. #ifndef errno
  43. extern int errno;
  44. #endif
  45.  
  46. #ifndef __GNUC__
  47. #define __inline /* empty */
  48. #endif
  49.  
  50. /* On some systems, @l@stat can return EINTR.  */
  51.  
  52. #ifndef EINTR
  53. # define SAFE_@L@STAT(name, buf) @l@stat (name, buf)
  54. #else
  55. # ifndef __static
  56. #   define __static static
  57. # endif
  58. # define SAFE_@L@STAT(name, buf) safe_@l@stat (name, buf)
  59. __static __inline int
  60. safe_@l@stat (const char *name, struct stat *buf)
  61. {
  62.   int ret;
  63.  
  64.   do
  65.     ret = @l@stat (name, buf);
  66.   while (ret < 0 && errno == EINTR);
  67.  
  68.   return ret;
  69. }
  70. #endif
  71.  
  72. #endif /* S_ISLNK */                        @LSTAT_ONLY@
  73.  
  74. #ifdef __cplusplus
  75. }
  76. #endif
  77.  
  78. #endif /* _safe_@l@stat_h_ */
  79.